Modular Specification of Encapsulated Object-Oriented Components

نویسندگان

  • Arnd Poetzsch-Heffter
  • Jan Schäfer
چکیده

fields may only depend on the fields of the box. interface SimpleGameObserver { Position observedPos; Game obsGame; } interface Game { Position currentPos; Color player; void move( MoveDescr md ) void swapPlayers() } Example: 3. Specification Technique: Invariants (1) Problems with invariant: • Where should they hold? • What are the fields they may depend on? • Invariants cause a modularity problem: Invariants of all classes have to hold in the prestate of a call! Specification invariant for GamingSystem: invariant forall o in obs: o.observedPos == o.obsGame.currentPos Example: class C { void me( D x ) { ... x.foo(); } } 3. Specification Technique: Invariants (2) • Invariants may only depend on the fields of the box. • Invariants have to hold whenever the thread is outside the box. • This helps to solve the modularity problem. Approach to invariants: • Implicit unpack/pack mechanism whenever box boundary is crossed. • Invariant may depend on execution state (type states). Discussion: 3. Specification Technique: Method Behavior (1) Method specification: • Changes to local state and result • Changes to the environment • What is left unchanged • Reentrance behavior Frame problem Example: box interface ObservableGame { references Observer* gameObs; ObservableGame() void move( MoveDescr md ) void register( external Observer go ) ... } interface Observer { void stateChanged() } 3. Specification Technique: Method Behavior (2) Existing approach to frame problem: • Describe what is allowed to be modified (modifies clause) • What is not mentioned in the modifies clause may not change • Loose coupling, information hiding, and abstraction is difficult to handle Box-based approach to frame problem: • Specify what is left unchanged in the box • Specify calls on external objects allows for modular verification 3. Specification Technique: Method Behavior (3) Technique for specifying outgoing calls: • Refinement calculi / grey box specifications (R. Back / M. Büchi) • ( Process calculi ) box interface ObservableGame { ... void move( MoveDescr md ) requires legal(md,currentPos) behavior currentPos = doMove(md,currentPos); forall o in gameObs { o.stateChanged() } any( cmd :: legal(cmd,currentPos) ) { currentPos = doMove(md,currentPos); forall o in gameObs { o.stateChanged() } } ensures unchanged([player,state,gameObs]) ... } Example: Problem: Reentrance DR AF T 3. Specification Technique: Method Behavior (4) Approach to reentrance: • Grey box specifications • Type states to restrict callable methods void move( MoveDescr md ) requires legal(md,currentPos) && state == VALID behavior state = OBSERVABLE; currentPos = doMove(md,currentPos); forall o in gameObs { o.stateChanged() } any( cmd :: legal(cmd,currentPos) ) { currentPos = doMove(md,currentPos); forall o in gameObs {o.stateChanged() } } state = VALID; } ensures unchanged([player,state,gameObs]) Example: Only readPos is executable if state == OBSERVABLE

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

A Fitness Function for Modular Evolutionary Testing of Object-Oriented Programs

We show that encapsulation of states in objectoriented programs hinders the search for test data using evolutionary testing. In a well-designed objectoriented program the encapsulated or hidden state is accessible only through exported or public methods. As client code is oblivious to the internal state of a server object, no guidance is available to test the client code using evolutionary test...

متن کامل

Towards imperative modules: Reasoning about invariants and sharing

Imperative and object-oriented programs make ubiquitous use of shared mutable objects. Updating a shared object can and often does transgress a boundary that was supposed to be established using static constructs such as a class with private fields. This paper shows how auxiliary fields can be used to express two state-dependent encapsulation disciplines: ownership, a kind of separation, and lo...

متن کامل

Object-Oriented Modelling with High-Level Modular Petri Nets

In this paper, we address the problem of expressing objectoriented concepts in terms of Petri nets. This is interesting, first, as a possibility of representing concurrent system specifications written in object-oriented formalisms or languages with Petri nets, and second, as a way of allowing automated verification of the obtained Petri net using existing reachability analysis tools. We start ...

متن کامل

An Algebraic Approach for the Specification and the Verification of Aspect- Oriented Systems

Aspect-Oriented (AO) Technology is a post-object-oriented technology used to overcome limitations of Object-Oriented (OO) Technology, such as the cross-cutting concern problem. Aspect-Oriented Programming (AOP) also offers modularity and traceability benefits. Yet, reasoning, specification, and verification of AO systems present unique challenges, especially as such systems evolve over time. Co...

متن کامل

Object-Oriented Action Semantics Specifications

Action Semantics is a framework for the formal specification of programming languages. Two different, recently proposed approaches provide modularity to the framework, allowing for specification reusability and extension. In this work, we analyze the previous approaches, and introduce Object-Oriented Action Semantics, a new form of modular organization of Action Semantics descriptions. Object-o...

متن کامل

Refinement of the PAC model for the component design and specification of television based interfaces

Componentisation of software promises to deliver cost efficiency that has not been achieved through object orientation [19]. PAC [5] is a popular conceptual architecture for structuring user interface software in an object oriented fashion. This paper reports our experience of adapting and refining PAC as a component architecture in the context of consumer electronics, and On-screen Displays in...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2005